package com.gpjcjl.http;

import androidx.annotation.NonNull;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by biao.yin on 2018/4/26.
 * 网络请求拦截器，进行日志输出
 * 使用方式new OkHttpClient.Builder().addInterceptor(new HttpLogInterceptor())
 *
 * @author yinbiao
 */

public class HttpHeaderInterceptor implements Interceptor {

    private static final String TAG = "HttpLogInterceptor";

    @Override
    @NonNull
    public Response intercept(@NonNull Chain chain) throws IOException {
        //        String token = SharedHelper.getInstance().getString(Constants.KEY_APPTOKEN, null);
        Request original = chain.request();
        Request.Builder builder = original.newBuilder();
        builder.method(original.method(), original.body());
        //        if (!TextUtils.isEmpty(token)) {
        //            builder.addHeader("APP-Authorization", token);
        //        }
        return chain.proceed(builder.build());
    }
}
